﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers {
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class UpdateBuildModeCommand extends Command {

        public var world:WorldModel;
        public var gameStateModel:GameStateModel;
        public var tutorialModel:TutorialModel;
        public var userModel:UserModel;

        override public function execute():void{
            if (this.userModel.isVisitFriendsMode()){
                return;
            };
            var _local1:Boolean;
            var _local2:Number = GameConstants.ACTORS_VISIBLE;
            var _local3:Number = GameConstants.ACTORS_VISIBLE;
            if (this.gameStateModel.isFacadeVisible){
                _local1 = false;
                _local2 = GameConstants.ACTORS_INVISIBLE;
                _local3 = GameConstants.ACTORS_INVISIBLE;
            } else {
                if (this.gameStateModel.isBuildMode){
                    _local1 = false;
                    _local2 = GameConstants.ACTORS_INVISIBLE;
                    _local3 = GameConstants.ACTORS_FADED;
                };
            };
            dispatch(new InfoEvent(EventConstants.ENABLE_MISSION_BUTTON, null, !(this.gameStateModel.isBuildMode)));
            var _local4:Object = {enabled:_local1, alpha:_local2};
            this.handleActors(this.world.doctors, {enabled:_local1, alpha:_local3});
            this.handleActors(this.world.patients, {enabled:_local1, alpha:_local2});
            this.handleActors(this.world.avatars, {enabled:_local1, alpha:_local2});
            this.handleActors(this.world.machines, {enabled:_local1, alpha:_local3});
            dispatch(new InfoEvent(EventConstants.FADE_ITEMS, null, _local4));
        }
        private function handleActors(_arg1:Array, _arg2:Object):void{
            var _local3:IActing;
            for each (_local3 in _arg1) {
                dispatch(new InfoEvent(EventConstants.FADE_ACTOR, _local3.id, _arg2));
            };
        }

    }
}//package net.wooga.pets.controllers 
